﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
using System.Windows.Media.Imaging;
using CoiffeurProject.Utils;

namespace CoiffeurProject.UserControls
{
    internal class NotificationBubble
    {
        private static readonly int DEFAULT_WIDTH = 38;
        private static readonly int DEFAULT_HEIGHT = 38;
        private static readonly int DEFAULT_FONT_SIZE = 24;

        Grid main_container;
        Image bubble;
        Label value;

        internal NotificationBubble(Thickness margin, int value, int width, int height, int grid_row, int grid_column)
        {
            main_container = new Grid()
            {
                Height = height,
                Width = width,
                Margin = margin,
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left
            };

            Grid.SetRow(main_container, grid_row);
            Grid.SetColumn(main_container, grid_column);

            bubble = new Image()
            {
                Height = height,
                Width = width,
                Stretch = Stretch.Fill,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(0),
                Source = new BitmapImage(new Uri(ImagesPath.NotificationIcon))
            };

            main_container.Children.Add(bubble);

            this.value = new Label()
            {
                Content = value,
                Height = height,
                Width = width,
                FontSize = (DEFAULT_FONT_SIZE * width) / DEFAULT_WIDTH,
                Foreground = new SolidColorBrush(Colors.White),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalContentAlignment = VerticalAlignment.Center,
                Margin = new Thickness(0,-4,0,0)
            };

            main_container.Children.Add(this.value);
        }

        public Grid MainContainer
        {
            get { return main_container; }
        }

        public void ChangeBubbleValue(int value)
        {
            this.value.Content = value;
        }
    }
}
